<template>
  <div>
    <p class="u-title">评论</p>
    <ul class="comment-box">
      <li v-for="item in arr" :key="item.time">
        <img :src="item.user.avatarUrl" class="avatarUrl" alt="" />
        <div class="comment-right">
          <p class="nickname">
            {{ item.user.nickname }}
            <span class="time">
              {{ item.time | fmtDate("MM月DD日 hh:mm") }}
            </span>
          </p>
          <p class="reply">回复我：{{ item.content }}</p>
          <p class="myreply">{{ item.beRepliedContent }}</p>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import { msgComments } from "@/api";
export default {
  data() {
    return {
      arr: [],
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      msgComments({ uid: this.$route.query.id }).then((res) => {
        this.arr = res.comments;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.comment-box {
  li {
    padding: 10px 0;
    .avatarUrl {
      width: 50px;
      height: 50px;
      margin-right: 10px;
    }
    display: flex;
    .comment-right {
      flex: 1;
      padding: 11px 20px 14px 20px;
      background: #f2f2f2;
      .nickname {
        color: #0c73c2;
        font-weight: bold;
        font-size: 12px;
        .time {
          float: right;
          color: #666;
          font-weight: 100;
        }
      }
      .reply {
        color: #333;
        margin-top: 10px;
      }
      .myreply {
        color: #999;
        margin-top: 10px;
      }
    }
  }
}
</style>